x86: perform mem_sharing teardown before paging teardown
authorTamas K Lengyel <tamas@tklengyel.com>
Fri, 3 Mar 2023 06:59:08 +0000 (07:59 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 3 Mar 2023 06:59:08 +0000 (07:59 +0100)
commite8f28e129d23c940749c66150a89c4ed683a0fb9
tree8c6db04418c6ccb9d4e76fd1adb043774220d840
parente9a7942f6c1638c668605fbf6d6e02bc7bff2582
x86: perform mem_sharing teardown before paging teardown

An assert failure has been observed in p2m_teardown when performing vm
forking and then destroying the forked VM (p2m-basic.c:173). The assert
checks whether the domain's shared pages counter is 0. According to the
patch that originally added the assert (7bedbbb5c31) the p2m_teardown
should only happen after mem_sharing already relinquished all shared pages.

In this patch we flip the order in which relinquish ops are called to avoid
tripping the assert. Conceptually sharing being torn down makes sense to
happen before paging is torn down.

Fixes: e7aa55c0aab3 ("x86/p2m: free the paging memory pool preemptively")
Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 2869349f0cb3a89dcbf1f1b30371f58df6309312
master date: 2023-02-23 12:35:48 +0100
xen/arch/x86/domain.c